<?php
namespace Admin\Controller;
use Admin\Controller\AdminController;
use Think\Page;

class PingqiangController extends AdminController {
	public function _initialize(){
        parent::_initialize();
    }
	
	 /**
     * 会员列表
     */
    public function index(){
		$cat = M('Cat')->select();
        $this->assign('cat', $cat);
        $name = I('name') ? I('name') : null;
        $cat_id = I('cat_id') ? I('cat_id') : null;
        if (!empty($name)) {
            $where['name'] = array("like", "%" . $name . "%");
        }
        if (!empty($cat_id)) {
            $where['cat_id'] = $cat_id;
        }
        $count = M('Goods')->where($where)->count();
        $Page = new Page($count, 8);
        setPageParameter($Page, array('name' => $name));
        $show = $Page->show();
        $list = M('Goods')->where($where)
                        ->limit($Page->firstRow . ',' . $Page->listRows)->order('goods_id desc')->select();
        foreach($list as $k=>$v){
            $go=M('rob_goods_orders');
            $num=$go->where(array('goods_id'=>$v['goods_id']))->count();//订单拼抢次数
            $ox=$go->where(array('goods_id'=>$v['goods_id']))->select();
            $list[$k]['num']=$num;
        }
        $this->assign('list', $list);
        $this->assign('search', $name);
        $this->assign('page', $show);
        $this->display();
		 
    }
	
	
}
	
